package cn.com.chengmandian.bike.service.impl;

import cn.com.chengmandian.bike.constants.FaultBillDealCreateType;
import cn.com.chengmandian.bike.model.EbFaultBillDeal;
import cn.com.chengmandian.bike.mapper.EbFaultBillDealMapper;
import cn.com.chengmandian.bike.model.EbMemberInfo;
import cn.com.chengmandian.bike.service.IEbFaultBillDealService;
import cn.com.chengmandian.bike.service.IEbFaultBillInfoService;
import cn.com.chengmandian.bike.service.IEbMemberInfoService;
import cn.com.chengmandian.bike.service.IEbMessageInfoService;
import cn.com.chengmandian.core.web.pojo.AgentUser;
import cn.com.chengmandian.core.web.utils.LocalMapUtil;
import cn.com.chengmandian.service.bike.constants.MessageBusinessTypeEnum;
import cn.com.chengmandian.service.bike.constants.MessageChannelEnum;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 电单车运营-订单问题工单-处理进度 服务实现类
 * </p>
 *
 * @author AutoGenerator
 * @since 2024-05-29
 */
@Service
public class EbFaultBillDealServiceImpl extends ServiceImpl<EbFaultBillDealMapper, EbFaultBillDeal> implements IEbFaultBillDealService {

    @Autowired
    private IEbMessageInfoService messageInfoService;
    @Autowired
    private IEbMemberInfoService memberInfoService;

    @Override
    public void createRecord(Integer billId, FaultBillDealCreateType dealCreateType, String content, String imgUrl, AgentUser agentUser) {
        EbMemberInfo memberInfo = memberInfoService.getById(agentUser.getId());

        EbFaultBillDeal faultBillDeal = new EbFaultBillDeal();
        faultBillDeal.setBillId(billId);
        faultBillDeal.setContent(content);
        faultBillDeal.setImgUrl(imgUrl);
        faultBillDeal.setCreateType(dealCreateType.getCode());
        if(memberInfo != null) {
            faultBillDeal.setCreateUser(memberInfo.getId());
            faultBillDeal.setCreateName(StrUtil.isBlank(memberInfo.getName()) ? memberInfo.getMobile() : memberInfo.getName());
        }
        faultBillDeal.setCreateTime(DateUtil.date());
        this.save(faultBillDeal);
    }
}
